<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="年度" prop="deviceName">
        <el-date-picker format="yyyy" value-format="yyyy" v-model="queryParams.year" type="year" placeholder="选择年">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['super:record:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['super:record:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="printBox"
          v-hasPermi="['super:record:print']">打印</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table @selection-change="handleSelectionChange" fit v-loading="loading" :data="dataList" border>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column show-overflow-tooltip label="流程状态" min-width="100">
        <template slot-scope="scope">
          <el-tag size="mini">{{ scope.row.statusName }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="检测项目" prop="jcxm">
        <template slot-scope="scope">
          {{ scope.row.jcxm || '其他' }}
        </template>

      </el-table-column>
      <el-table-column show-overflow-tooltip label="监督对象" prop="jddxName">

      </el-table-column>
      <el-table-column show-overflow-tooltip label="监督日期" prop="jdrq" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="240" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" v-hasPermi="['super:record:info']"
            @click="handleDetail(scope.row)">详情</el-button>
          <el-button v-if="scope.row.status === 'draft'" icon="el-icon-edit" size="mini" type="text"
            v-hasPermi="['super:record:edit']" @click="handleUpdate1(scope.row)">修改</el-button>
            <el-button v-if="scope.row.status === 'draft'" icon="el-icon-edit" size="mini" type="text"
            v-hasPermi="['super:record:del']" @click="handleDelete(scope.row)">删除</el-button>
          <el-button v-if="scope.row.status === 'end'" icon="el-icon-edit" size="mini" type="text"
            v-hasPermi="['super:record:edit']" @click="handleUpdate(scope.row)">补充信息</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 打印模板位置 -->
    <PrintBox :printRow="printList" checkLabel="checkLabel" :isVertical="false" id="printBox" :paddrg="80">
      <template slot="title" slot-scope="scope">
        <div style="margin-bottom: 40px">
          监督记录表 STET/B/27-1
        </div>
      </template>
      <template slot-scope="scope">
        <!-- 表格  class  table-page  必须-->
        <table style="border-collapse: collapse; table-layout: fixed; width: 90%" border="1" cellspacing="0"
          class="table-page" :isVertical="false">
          <tr class="table_header" style="height: 20mm;">
            <td style="width: 40mm;font-size: 16px">监督员</td>
            <td style="width: 80mm;font-size: 16px">{{ scope.item.jdyName }}</td>
            <td style="width: 40mm;font-size: 16px">监督对象</td>
            <td style="width: 80mm;font-size: 16px">
              {{ scope.item.jddxName }}
            </td>
          </tr>
          <tr class="table_header" style="height: 20mm;">
            <td style="width: 40mm;font-size: 16px">检测项目</td>
            <td style="width: 80mm;font-size: 16px">{{ scope.item.jcxm }}</td>
            <td style="width: 40mm;font-size: 16px">监督日期</td>
            <td style="width: 80mm;font-size: 16px">
              {{ scope.item.jdrq }}
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">监督重点</td>
            <td colspan="3" style="font-size: 16px;">
              <div style="display: flex; align-items: center; margin-left:20px">
                新上岗人员<input type="checkbox" :checked="(scope.item.jdzd.split(',')).includes('新上岗人员')" />
                转岗人员 <input type="checkbox" :checked="(scope.item.jdzd.split(',')).includes('转岗人员')" />
                <div style="margin-left:20px;display:flex;"> 其他：<div
                    style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.jdzdQt }}</div>;</div>
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">监督形式</td>
            <td colspan="3" style="font-size: 16px;">
              <div style="display: flex; align-items: center; margin-left:20px">
                提问<input type="checkbox" :checked="(scope.item.jdxs.split(',')).includes('提问')" />
                实际操作 <input type="checkbox" :checked="(scope.item.jdxs.split(',')).includes('实际操作')" />
                检查技术资料（详见附件） <input type="checkbox" :checked="(scope.item.jdxs.split(',')).includes('检查技术资料(详见附件)')" />
              </div>
            </td>
          </tr>
          <tr style="">
            <td style="font-size: 16px;height: 40px">监督内容</td>
            <td colspan="3" style="font-size: 16px;height: 40px">监督情况说明</td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">委托书(现场检测、业务大厅)</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                委托证书信息是否齐全：
                是 <input type="checkbox" :checked="scope.item.wtsSfqq == 0" />
                否 <input type="checkbox" :checked="scope.item.wtsSfqq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                检测依据是否明确：
                是 <input type="checkbox" :checked="scope.item.wtsSfmq == 0" />
                否 <input type="checkbox" :checked="scope.item.wtsSfmq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.wtsQt }}</div>;
                <!-- <input type="text" v-model="" :border="false"   /> -->
                不适用<input type="checkbox" :checked="scope.item.wtsBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">人员</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                是否具备上岗资格：
                是 <input type="checkbox" :checked="scope.item.rySgzg == 0" />
                否 <input type="checkbox" :checked="scope.item.rySgzg == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.ryQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.ryBsy == 1" />
              </div>
            </td>
          </tr>

          <tr style="height: 20mm">
            <td style="font-size: 16px;">设备</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                所选设备（量程及精度等）是否满足规范要求：
                是 <input type="checkbox" :checked="scope.item.sbGfyq == 0" />
                否 <input type="checkbox" :checked="scope.item.sbGfyq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                设备是否在有效的检定/校准周期内，且检定/校准满足要求：
                是 <input type="checkbox" :checked="scope.item.sbJdyq == 0" />
                否 <input type="checkbox" :checked="scope.item.sbJdyq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.sbQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.sbBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">样品</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                流转过程中是否具备唯一性标识：
                是 <input type="checkbox" :checked="scope.item.ypWybs == 0" />
                否 <input type="checkbox" :checked="scope.item.ypWybs == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                是否及时标注样品检测状态：
                是 <input type="checkbox" :checked="scope.item.ypJczt == 0" />
                否 <input type="checkbox" :checked="scope.item.ypJczt == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                样品制备、状态调节是否满足规范要求：
                是 <input type="checkbox" :checked="scope.item.ypGfyq == 0" />
                否 <input type="checkbox" :checked="scope.item.ypGfyq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.ypQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.ypBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">检测依据</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                检测依据是否现行有效，特殊情况是否取得客户同意：
                是 <input type="checkbox" :checked="scope.item.jcyjKhty == 0" />
                否 <input type="checkbox" :checked="scope.item.jcyjKhty == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.jcyjQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.jcyjBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">检测环境</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                检测环境（温度、湿度等）是否满足规范要求：
                是 <input type="checkbox" :checked="scope.item.jchjGfyq == 0" />
                否 <input type="checkbox" :checked="scope.item.jchjGfyq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.jchjQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.jchjBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">检测过程</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                是否按照所选用的检测依据进行试验：
                是 <input type="checkbox" :checked="scope.item.jcghJxsy == 0" />
                否 <input type="checkbox" :checked="scope.item.jcghJxsy == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                设备操作、检测过程是否熟练：
                是 <input type="checkbox" :checked="scope.item.jcgcCzsl == 0" />
                否 <input type="checkbox" :checked="scope.item.jcgcCzsl == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                设备台账是否记录及时：
                是 <input type="checkbox" :checked="scope.item.jcgcJsjl == 0" />
                否 <input type="checkbox" :checked="scope.item.jcgcJsjl == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                现场安全措施是否布置到位：
                是 <input type="checkbox" :checked="scope.item.jcgcAqdw == 0" />
                否 <input type="checkbox" :checked="scope.item.jcgcAqdw == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.jcgcQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.jcgcBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">原始记录</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                原始记录是否为受控版本：
                是 <input type="checkbox" :checked="scope.item.ysjlSkbb == 0" />
                否 <input type="checkbox" :checked="scope.item.ysjlSkbb == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                原始记录填写是否规范、完整：
                是 <input type="checkbox" :checked="scope.item.ysjlSfgf == 0" />
                否 <input type="checkbox" :checked="scope.item.ysjlSfgf == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                原始记录数据是否准确：
                是 <input type="checkbox" :checked="scope.item.ysjlSfzq == 0" />
                否 <input type="checkbox" :checked="scope.item.ysjlSfzq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.ysjlQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.ysjlBsy == 1" />
              </div>
            </td>
          </tr>

          <tr style="height: 20mm">
            <td style="font-size: 16px;">检测报告</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                编制的检测报告信息内容是否存在不一致性：
                是 <input type="checkbox" :checked="scope.item.jcbgByzx == 0" />
                否 <input type="checkbox" :checked="scope.item.jcbgByzx == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                编制的检测报告的信息内容是否满足规范及质量体系要求：
                是 <input type="checkbox" :checked="scope.item.jcbgTxyq == 0" />
                否 <input type="checkbox" :checked="scope.item.jcbgTxyq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                编制的检测报告的数据处理是否准确：
                是 <input type="checkbox" :checked="scope.item.jcbgSjsfzq == 0" />
                否 <input type="checkbox" :checked="scope.item.jcbgSjsfzq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                编制的检测报告的结论是否准确：
                是 <input type="checkbox" :checked="scope.item.jcbgJlsfzq == 0" />
                否 <input type="checkbox" :checked="scope.item.jcbgJlsfzq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                编制的检测报告的审核、批准流程是否正确，且人员是否满足行业及质量体系要求：
                是 <input type="checkbox" :checked="scope.item.jcbgYq == 0" />
                否 <input type="checkbox" :checked="scope.item.jcbgYq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.jcbgQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.jcbgBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">工作程序（业务大厅）</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                样品收样数量及状态是否满足规范检测要求：
                是 <input type="checkbox" :checked="scope.item.gzcxGfyq == 0" />
                否 <input type="checkbox" :checked="scope.item.gzcxGfyq == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                发样过程是否能够保持样品的唯一性标识：
                是 <input type="checkbox" :checked="scope.item.gzcxWybs == 0" />
                否 <input type="checkbox" :checked="scope.item.gzcxWybs == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                留样过程符合规范及及质量体系要求、入库出库登记及时、准确：
                是 <input type="checkbox" :checked="scope.item.gzcxRkdj == 0" />
                否 <input type="checkbox" :checked="scope.item.gzcxRkdj == 1" />
              </div>
              <div style="display: flex; align-items: center; ">
                其他：<div style="min-width:100px;height:25px;border-bottom:1px solid #333">{{ scope.item.gzcxQt }}</div>;
                不适用<input type="checkbox" :checked="scope.item.gzcxBsy == 1" />
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">监督结论</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                该监督对象
                存在 <input type="checkbox"
                  :checked="(checkHistoryNodeComment(scope, 'zljdy').message.split('*')[0]).split(',')[0] == '存在'" />
                不存在 <input type="checkbox"
                  :checked="(checkHistoryNodeComment(scope, 'zljdy').message.split('*')[0]).split(',')[0] == '不存在'" />
                <div style="margin-left:20px"
                  v-if="(checkHistoryNodeComment(scope, 'zljdy').message.split('*')[0]).split(',')[0] == '存在'">描述(若存在){{
                    (checkHistoryNodeComment(scope, 'zljdy').message.split('*')[0]).split(',')[2] }}</div>
              </div>
              <div style="display: flex; align-items: center; ">
                工作能力：
                具备 <input type="checkbox"
                  :checked="(checkHistoryNodeComment(scope, 'zljdy').message.split('*')[0]).split(',')[1] == '是'" />
                不具备 <input type="checkbox" :checked="(checkHistoryNodeComment(scope, 'zljdy').message.split('*')[0]).split(',')[1] == '否'
                  " />
              </div>

              <div style="
                  display: flex;
                  justify-content: flex-end;
                  text-align: left;
                  margin-top: 20px;
                ">
                <div style="width: 50mm; position: relative">
                  质量监督员：
                  <template v-if="CheckApprove(scope, 'zljdy').ShowImg">
                    <img style="width: 80px; position: absolute; top: -10px"
                      :src="CheckApprove(scope, 'zljdy').ApproveImg" />
                  </template>
                </div>
                <div style="width: 40mm">日期： {{ checkHistoryNode(scope, "zljdy").commentList[0].time.substr(0, 10) }}
                </div>
              </div>
            </td>

          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">监督对象确认</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">
                对监督结果是否有异议：
                是 <input type="checkbox" :checked="checkHistoryNodeComment(scope, 'jddx').type == 1" />
                否 <input type="checkbox" :checked="checkHistoryNodeComment(scope, 'jddx').type == 2 ||
                  checkHistoryNodeComment(scope, 'jddx').type == 3
                  " />
              </div>
              <div style="
                  display: flex;
                  justify-content: flex-end;
                  text-align: left;
                  margin-top: 20px;
                ">
                <div style="width: 40mm; position: relative">
                  监督对象
                  <template v-if="CheckApprove(scope, 'jddx').ShowImg">
                    <img style="width: 80px; position: absolute; top: -10px"
                      :src="CheckApprove(scope, 'jddx').ApproveImg" />
                  </template>
                </div>
                <div style="width: 40mm">日期： {{ checkHistoryNode(scope, "jddx").commentList[0].time.substr(0, 10) }}
                </div>
              </div>
            </td>
          </tr>
          <tr style="height: 20mm">
            <td style="font-size: 16px;">后续处理</td>
            <td colspan="3" style=";padding:10px;font-size: 16px">
              <div style="display: flex; align-items: center; ">

                可以上岗<input type="checkbox" :checked="checkHistoryNodeComment(scope, 'bmfzr').type == 1" />
                不可上岗（需培训后重新监督） <input type="checkbox" :checked="checkHistoryNodeComment(scope, 'bmfzr').type == 2 ||
                  checkHistoryNodeComment(scope, 'bmfzr').type == 3
                  " />
              </div>
              <div style="
                  display: flex;
                  justify-content: flex-end;
                  text-align: left;
                  margin-top: 20px;
                ">
                <div style="width: 60mm; position: relative">
                  监督对象部门负责人
                  <template v-if="CheckApprove(scope, 'bmfzr').ShowImg">
                    <img style="width: 80px; position: absolute; top: -10px"
                      :src="CheckApprove(scope, 'bmfzr').ApproveImg" />
                  </template>
                </div>
                <div style="width: 40mm">日期： {{ checkHistoryNode(scope, "bmfzr").commentList[0].time.substr(0, 10) }}
                </div>
              </div>
            </td>
          </tr>
        </table>
        <!-- 底部信息位置 -->
        <div class="page-bottom" style="page-break-after: always">
          <div class="desc">注：本表格自2021年6月1日起生效。</div>
        </div>
      </template>
    </PrintBox>
  </div>
</template>
  
<script>
// import {
//   listCultivateYearPlan,
//   delCultivateYearPlan,
// } from "@/api/cultivate/yearPlan.js";
import {
  listRecord,
  delQualitySupervisionRecord
} from "@/api/quality/supervision/record.js";
import { deptTreeSelect } from "@/api/system/user.js";
import {
  list,
  delMonitorLedger,
  monitorExport,
} from "@/api/monitor/inOutMonitor.js";
import printStyle from "@/utils/print.js";

export default {
  name: "yearPlan",
  dicts: ["sys_device_check_type"],

  data() {
    return {
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      dataList: [],
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      deptOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        deviceName: undefined,
        operUserId: undefined,
        licenseNum: undefined,
        checkDate: null,
        type: 1,
      },
      // 日期范围
      dateRange: [],
      userList: [],
      deptOptions: [],
      infos: [], //勾选的数据
      printList: [],
    };
  },
  created() {
    const str = sessionStorage.getItem('queryParams');
    if (str) {
      this.queryParams = JSON.parse(str);
      setTimeout(() => {
        sessionStorage.removeItem('queryParams');
      }, 500)
    }
    this.getList();
    this.getDeptTree();
  },
  methods: {
    printBox() {
      //infos  勾选的数据 如果有勾选就打印勾选。
      if (this.infos.length) {
        this.printList = this.infos;
      } else {
        //反之打印当前整个列表
        this.printList = this.dataList;
      }
      setTimeout(() => {
        document.title = "年度质量监控计划表 STET/B/26-1";
        this.$print({
          printable: "printBox", //打印区域id
          type: "html", //打印类型是html
          scanStyles: false,
          targetStyles: ["*"],
          style: this.workStyle(),
          onPrintDialogClose: () => {
            document.title = process.env.VUE_APP_TITLE;
          },
        });
      }, 500);
    },
    // 可以自定义样式  printStyle 是公共样式 切勿私自修改
    workStyle() {
      return `${printStyle}
          table,
          table tr th,
          table tr td {
            height:17mm;
            padding: 0px;
            font-size: 12px;
          }
          .desc{
          text-align: left; font-size: 12px; margin-top: 10px
        }
              .df {
                  display: flex;
                }
        `;
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.qualityMonitorPlanItemId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
      this.infos = selection;
    },
    handleUpdate1(row) {
      sessionStorage.setItem('queryParams', JSON.stringify(this.queryParams));

      console.log(row);
      const configId = row.qualityMonitorPlanItemId || this.ids;
      this.$router.push("./addRecord?isEdit=true&id=" + configId);
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      sessionStorage.setItem('queryParams', JSON.stringify(this.queryParams));

      console.log(row);
      const configId = row.qualityMonitorPlanItemId || this.ids;
      this.$router.push("./addRecord?isEdit=true&id=" + configId);
    },
    /** 查询部门下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data;
      });
    },
    handleDetail(row) {
      sessionStorage.setItem('queryParams', JSON.stringify(this.queryParams));
      if (row.status == 'draft') {
        this.$router.push(
          "./addRecord?isInfo=true&id=" + row.qualityMonitorPlanItemId
        );
      } else {
        this.$router.push({
          path: "/monitorIn/process/detail/" + row.piid,
          query: {
            definitionId: null,
            deployId: null,
            taskId: null,
            finished: false,
            id: row.qualityMonitorPlanItemId,
          },
        });
      }

    },

    /** 删除按钮操作 */
    handleDelete(row) {
      const configId = row.qualityMonitorPlanItemId || this.ids;
      let name = this.checkRow(
        configId,
        this.dataList,
        "qualityMonitorPlanItemId",
        "DELETE",
        "year"
      );
      this.$modal
        .confirm('是否确认删除年度为"' + name + '"的数据项？')
        .then(function () {
          return delQualitySupervisionRecord(configId);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { });
    },
    handleAdd() {
      this.$router.push("./addRecord");
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      listRecord(
        this.addDateRangeTime(
          this.queryParams,
          this.dateRange,
          "startEndDate",
          "endEndDate"
        )
      ).then((response) => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleExport() {
      this.download(
        "system/monitor/export",
        {
          ...this.queryParams,
        },
        `内部质量监控表_${this.parseTime(
          new Date().getTime(),
          "{y}-{m}-{d}"
        )}.xlsx`
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      // this.dateRange = [];
      this.queryParams.year = "";
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
  img {
    width: 100%;
  }
}
</style>

  